package com.ky.pro.java.nio.http.server.router;

import java.net.InetSocketAddress;

/**
 * @ClassName GatewayRouter
 * @Description TODO
 * @Date 2021/11/20 17:17
 * @Author kevin
 **/
public class GatewayRouter {

    private IGatewayRouterRule rule;

    private ServiceRegistrar serviceRegistrar;

    public GatewayRouter(IGatewayRouterRule rule, ServiceRegistrar serviceRegistrar) {
        this.rule = rule;
        this.serviceRegistrar = serviceRegistrar;
    }

    public InetSocketAddress findServiceAddress(String serviceName) {
        return rule.findServers(serviceRegistrar.getAddressSet(serviceName));
    }

}
